package com.hmsproject.socialAuth;

import java.io.IOException;
import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

import com.hmsproject.search.managedbean.SearchView;

@ManagedBean
@SessionScoped
public class FacebookNavgiation implements Serializable {
	
		 
	/**
	 * 
	 */
	private static final long serialVersionUID = -6955954780815653970L;
	
	private boolean fromDealPage;
	
	@ManagedProperty("#{facebookBean}")
	private FacebookBean facebookBean;

	public boolean isFromDealPage() {
		return fromDealPage;
	}

	public void setFromDealPage(boolean fromDealPage) {
		this.fromDealPage = fromDealPage;
	}

	public FacebookBean getFacebookBean() {
		return facebookBean;
	}

	public void setFacebookBean(FacebookBean facebookBean) {
		this.facebookBean = facebookBean;
	}

	public void facebookRedirection() throws IOException {
	  
		if (fromDealPage)
		{
			    facebookBean.pullUserInfo();
			    this.fromDealPage=false;
				ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
		        ec.redirect(ec.getRequestContextPath()+"/deal/buyDeal.xhtml?faces-redirect=true");
			
		}
	}
	
	
}
	
	